<?php if (!defined('THINK_PATH')) exit();?>
<div class="region-input-div wd70 fl">

<div class="layui-input-inline wd100 mb10 region-item <?php if(($crmsite["regionType"]) != "world"): ?>hidden<?php endif; ?>">

	<select name="<?php echo ($FormName); ?>[<?php echo ($form_name); ?>_defaultCountry]" id="country<?php echo $reg; ?>" lay-ignore >

		<option value=""><?php echo L('PLEASE_SELECT');?></option>

		<?php if(is_array($country)): $i = 0; $__LIST__ = $country;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vc): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vc["code"]); ?>" <?php if(($crmsite["regionType"]) != "world"): if(($vc["code"]) == "1"): ?>selected<?php endif; else: if(($crmsite["defaultCountry"]) == $vc["code"]): ?>selected<?php endif; endif; ?>><?php echo ($vc["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>

	</select>

</div>

<div class="layui-input-inline wd100 mb10 <?php if(empty($crmsite["defaultProv"])): ?>hidden<?php endif; ?> layui-form region-item" lay-filter="province">

	<select  name="<?php echo ($FormName); ?>[<?php echo ($form_name); ?>_defaultProv]" lay-filter="select-province<?php echo $reg; ?>" id="province<?php echo $reg; ?>" lay-ignore >

		<option value=""><?php echo L('PLEASE_SELECT');?></option>

		<?php if(!empty($crmsite["defaultProv"])): if(is_array($province)): $i = 0; $__LIST__ = $province;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vc): $mod = ($i % 2 );++$i;?><option c-value="<?php echo ($vc["country_code"]); ?>" value="<?php echo ($vc["code"]); ?>" <?php if(($crmsite["defaultProv"]) == $vc["code"]): ?>selected<?php endif; ?>><?php echo ($vc["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; endif; ?>

	</select>

</div>

<div class="layui-input-inline wd100 mb10 <?php if(empty($crmsite["defaultCity"])): ?>hidden<?php endif; ?> layui-form region-item" lay-filter="city">

	<select  name="<?php echo ($FormName); ?>[<?php echo ($form_name); ?>_defaultCity]" lay-filter="select-city<?php echo $reg; ?>" id="city<?php echo $reg; ?>" lay-ignore >

		<option value=""><?php echo L('PLEASE_SELECT');?></option>

		<?php if(!empty($crmsite["defaultCity"])): if(is_array($city)): $i = 0; $__LIST__ = $city;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vc): $mod = ($i % 2 );++$i;?><option c-value="<?php echo ($vc["country_code"]); ?>" p-value="<?php echo ($vc["province_code"]); ?>" value="<?php echo ($vc["code"]); ?>" <?php if(($crmsite["defaultCity"]) == $vc["code"]): ?>selected<?php endif; ?>><?php echo ($vc["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; endif; ?>

	</select>

</div>

<div class="layui-input-inline wd100 mb10 <?php if(empty($crmsite["defaultArea"])): ?>hidden<?php endif; ?> layui-form region-item" lay-filter="area">

	<select  name="<?php echo ($FormName); ?>[<?php echo ($form_name); ?>_defaultArea]" lay-filter="select-area<?php echo $reg; ?>" id="area<?php echo $reg; ?>" lay-ignore >

		<option value=""><?php echo L('PLEASE_SELECT');?></option>

		<?php if(!empty($crmsite["defaultArea"])): if(is_array($area)): $i = 0; $__LIST__ = $area;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$vc): $mod = ($i % 2 );++$i;?><option value="<?php echo ($vc["code"]); ?>" <?php if(($crmsite["defaultArea"]) == $vc["code"]): ?>selected<?php endif; ?>><?php echo ($vc["name"]); ?></option><?php endforeach; endif; else: echo "" ;endif; endif; ?>

	</select>

</div>

</div>

<i class="layui-icon layui-icon-about intro-icon fl blue8 ml10" data-note="<?php echo L('ENTER_NAME_SEARCH');?>"></i>

<script type="text/javascript">

	$("#country<?php echo $reg; ?>").select2();

	$("#province<?php echo $reg; ?>").select2();

	$("#city<?php echo $reg; ?>").select2();

	$("#area<?php echo $reg; ?>").select2();

	if($("#country<?php echo $reg; ?>").val() && !$("#province<?php echo $reg; ?>").val())
	{
		selectProvince('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	}

	if($("#province<?php echo $reg; ?>").val() && !$("#city<?php echo $reg; ?>").val())
	{
		selectCity('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	}

	if($("#city<?php echo $reg; ?>").val() && !$("#area<?php echo $reg; ?>").val())
	{
		selectArea('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	}

    $("#country<?php echo $reg; ?>").change(function()
	{
		selectProvince('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	})

    $("#province<?php echo $reg; ?>").change(function()
	{
		selectCity('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	})

    $("#city<?php echo $reg; ?>").change(function()
	{
		selectArea('<?php echo $reg; ?>',"<?php echo U('AjaxRequest/getRegion');?>");
	})

</script>